using System;
using System.Collections.Generic;
using System.Text;
using Google.GData.Client;
using Google.GData.Contacts;
using System.IO;
using System.Xml;
using Microsoft.Office.Interop.Outlook;

namespace ContactsTester
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please Enter you Gmail UserName");
            string UserName = Console.ReadLine();

            if (@UserName != null)
                if (!@UserName.Contains("@"))
                {
                    UserName += "@gmail.com";
                }

            Console.WriteLine("Please Enter you Gmail Password");

            string pass = Console.ReadLine();

            Console.WriteLine("Please select sync option");

            Console.WriteLine("1:Sync Outlook and Gmail");
            Console.WriteLine("2:Dump Contacts To/From a vCard file");
            Console.WriteLine("3:Upload Contacts to remote vCard");
            string selection = Console.ReadLine();

            Console.WriteLine("Starting");
            string UserMode = "";
            SyncManager currentManager = new SyncManager(UserName, pass, UserMode);
            switch (selection)
            {
                case "1":
                    Console.WriteLine("Please Select Sync Mode to use when encountering a existing contact");
                    Console.WriteLine("Sync Up to Gmail : enter G");
                    Console.WriteLine("Sync Down to outlook : enter O");
                    UserMode = Console.ReadLine();
                    currentManager = new SyncManager(UserName, pass, UserMode);
                    currentManager.SyncContacts();
                    break;
                case "2":
                    Console.WriteLine("1:Write Google Contacts To File");
                    Console.WriteLine("2:Write Outlook Contacts To File");
                    Console.WriteLine("3:Write All Contacts To File");
                    Console.WriteLine("4:Write contacts from vCard file To Google");
                    string newSelection = Console.ReadLine();
                    switch (newSelection)
                    {
                        case "1":
                            currentManager.SaveGoogleContactsTovFile();
                            break;
                        case "2":
                            currentManager.SaveGoogleContactsTovFile();
                            break;
                        case "3":
                            currentManager.SaveAllContactsTovCardFile();
                            break;
                        case "4":
                            Console.WriteLine("Please Enter the path to the vCard");
                            string filePath = Console.ReadLine();
                            currentManager.SaveVcardContactsToGoogle(filePath);
                            break;
                        default:
                            break;
                    }
                    break;
                case "3":
                    currentManager.SaveGoogleContactsToMobileFile();
                    break;
                default:
                    break;
            }
            Console.WriteLine("Sync Complete Hit any key to exit");
            Console.ReadKey();
        }
    }
}
